package com.yjq.programmer.controller.admin;

import com.yjq.programmer.dto.PageDTO;
import com.yjq.programmer.dto.ResponseDTO;
import com.yjq.programmer.dto.SingerDTO;
import com.yjq.programmer.service.ISingerService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 杨杨吖
 * @QQ 823208782
 * @WX yjqi12345678
 * @create 2022-11-14 11:35
 */
@RestController("AdminSingerController")
@RequestMapping("/admin/singer")
public class SingerController {

    @Resource
    private ISingerService singerService;

    /**
     * 分页获取歌手数据
     * @param pageDTO
     * @return
     */
    @PostMapping("/list")
    public ResponseDTO<PageDTO<SingerDTO>> getSingerListByPage(@RequestBody PageDTO<SingerDTO> pageDTO){
        return singerService.getSingerListByPage(pageDTO);
    }

    /**
     * 保存歌手数据(添加、修改)
     * @param singerDTO
     * @return
     */
    @PostMapping("/save")
    public ResponseDTO<Boolean> saveSinger(@RequestBody SingerDTO singerDTO){
        return singerService.saveSinger(singerDTO);
    }

    /**
     * 删除歌手数据
     * @param singerDTO
     * @return
     */
    @PostMapping("/remove")
    public ResponseDTO<Boolean> removeSinger(@RequestBody SingerDTO singerDTO){
        return singerService.removeSinger(singerDTO);
    }

    /**
     * 获取全部歌手数据
     * @return
     */
    @PostMapping("/all")
    public ResponseDTO<List<SingerDTO>> getAllSinger() {
        return singerService.getAllSinger();
    }

    /**
     * 获取歌手总数
     * @return
     */
    @PostMapping("/total")
    public ResponseDTO<Integer> getSingerTotal(){
        return singerService.getSingerTotal();
    }
}
